using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CMS_SUN_IF_Extraction
{
    public partial class frmExtract_Checking_List_Form : Form
    {
        private BAL bao = new BAL();
        DataTable tbl = null;
        public frmExtract_Checking_List_Form()
        {
            InitializeComponent();
        }

        private void btnList_Click(object sender, EventArgs e)
        {
            tbl = null;
            if (btnList.Text == "Full List")
            {
                groupBox2.Text = "Full list ..";
                btnList.Text = "Final Output List";
                //sf_Extract_Checking_List
                tbl = bao.get_lst_Extract_Checking();                                   
            }
            else
            {
                groupBox2.Text = "Final Output list ..";
                btnList.Text = "Full List";
                //sf_Extract_Final_Output
                tbl = bao.get_lst_Extract_Final_Output();
                int t = tbl.Rows.Count;
            }
            if (tbl != null && tbl.Rows.Count>0)
            {
                //lstExtract_Checking.Columns["VAT #"].Frozen = true;                
            }
            bindingSource1.DataSource = tbl;
            bindingSource1.ResetBindings(false);
            format_grid();
            lstExtract_Checking.Font = new Font("Arial", 9);
            label2.Text = tbl.Rows.Count.ToString();
        }

        private void format_grid()
        {
            foreach (DataGridViewColumn col in lstExtract_Checking.Columns)
            {
                if (col.Name == "Amount" )
                {
                    col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    col.DefaultCellStyle.Format = "0,0.00";
                }
                if (col.Name == "VN_Amount")
                {
                    col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    col.DefaultCellStyle.Format = "0,0";
                }
                if (col.Name == "Invoice Dt" || col.Name == "Payment Dt")
                {
                    col.DefaultCellStyle.Format = "dd-MMM-yyyy";
                }
            }
        }

        private void Extract_Checking_List_Form_Load(object sender, EventArgs e)
        {
            groupBox2.Text = "Full list ..";
            lstExtract_Checking.DataSource = bindingSource1;            
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}